nx=600;
ny=60;

nl=15;
r=6;

a=zeros(nx,ny);
for i=0:round(nx/nl)
    
    
    if mod(i,2)==0
    for j=0:2:round(ny/nl)
        
        
        for lx=(i*nl-r):(i*nl+r)
            for ly=(j*nl-r):(j*nl+r)
                if (((lx-i*nl)*(lx-i*nl)+(ly-j*nl)*(ly-j*nl)<=r*r) && (lx>0) && (ly>0) && (lx<=nx) &&(ly<=ny)) 
                    a(lx,ly)=1;
                end
            end
        end
    end
    
    
    else
        
        
     for j=1:2:round(ny/nl)
        
        
        for lx=(i*nl-r):(i*nl+r)
            for ly=(j*nl-r):(j*nl+r)
                if (((lx-i*nl)*(lx-i*nl)+(ly-j*nl)*(ly-j*nl)<=r*r) && (lx>0) && (ly>0) && (lx<=nx) &&(ly<=ny)) 
                    a(lx,ly)=1;
                end
            end
        end
     end
     
    end
    
    
    
    
    
end

fid = fopen('BC2.dat','wt');

for j=1:ny
    for i=1:nx
        fprintf(fid,'%1d\n',a(i,j));
    end
end



